import UserCardDetail from './userCard'
import NotFriend from './NotFriend'


export default {
  install(Vue) {
    function user(user_id, options) {
      console.log(user_id)
      let vNode = UserCardDetail;
      // if (user_id % 2) vNode = NotFriend;


      let _vm = this
      const el = new Vue({
        router: _vm.$router,
        store: _vm.$store,
        render(h) {
          return h(vNode, {
            on: {
              close: () => {
                el.$destroy()
                document.body.removeChild(el.$el)
              },
              editUser: data => {
                options.editDataCallbak && options.editDataCallbak(data);
                el.$destroy()
                document.body.removeChild(el.$el)
              }
            },
            props: {
              user_id,
              options
            },
          })
        },
      }).$mount()

      document.body.appendChild(el.$el)
    }

    Vue.prototype.$user = user
  },
}